package com.example.service;

import com.example.entity.Clockingtime;
import com.example.mapper.ClockingtimeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
用户打卡时间业务处理
 */
@Service
public class ClockingtimeService {

    @Resource
    private ClockingtimeMapper clockingtimeMapper;

    public void add(Clockingtime clockingtime) {
        clockingtimeMapper.insert(clockingtime);
    }

    public void deleteById(Integer id) {
        clockingtimeMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public Clockingtime selectByUid(Clockingtime clockingtime) {
        return clockingtimeMapper.selectByUid(clockingtime);
    }

    public void updateById(Clockingtime clockingtime) {
        clockingtimeMapper.updateById(clockingtime);
    }

    public Clockingtime selectById(Integer id) {
        return clockingtimeMapper.selectById(id);
    }

    public List<Clockingtime> selectAll(Clockingtime clockingtime) {
        return clockingtimeMapper.selectAll(clockingtime);
    }

    public PageInfo<Clockingtime> selectPage(Clockingtime clockingtime, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Clockingtime> clockingtimeList = clockingtimeMapper.selectAll(clockingtime);
        return PageInfo.of(clockingtimeList);
    }
}
